package me.jessyan.mvparms.demo.mvp.model.entity;


import java.io.Serializable;

import me.jessyan.mvparms.demo.mvp.model.Api;


/**
 * 如果你服务器返回的数据固定为这种方式(字段名可根据服务器更改)
 * 替换范型即可重用BaseJson
 * Created by jess on 26/09/2016 15:19
 * Contact with jess.yan.effort@gmail.com
 */

public class BaseJson<T> implements Serializable {
    private T result;
    private String code;
    private String msg;
    private int status;
    private OtherJson other;

    public BaseJson(T result, String code, String msg,int status) {
        this.result = result;
        this.code = code;
        this.msg = msg;
        this.status = status;
    }

    public T getResult() {
        return result;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public void setResult(T result) {
        this.result = result;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public OtherJson getOther() {
        return other;
    }

    public void setOther(OtherJson other) {
        this.other = other;
    }

    /**
     * 请求是否成功
     *
     * @return
     */
    public boolean isSuccess() {
        if (code.equals(Api.RequestSuccess)) {
            return true;
        } else {
            return false;
        }
    }
}
